<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="action_plan_work" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 增加流程 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="生产产品" prop="">
              {{action_plan_work.product_id}}
              <el-button @click="popChoiceProduct('','product_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="生产工艺" prop="">
              {{action_plan_work.category_id}}
              <el-button @click="popProduceFlowSelect('','category_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item>
              <el-button @click="produceFlowAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>增加</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </el-form>
    <el-dialog :visible.sync="ChoiceProductVisible" append-to-body>
      <ChoiceProduct v-if="ChoiceProductVisible" ref="ChoiceProduct" :popparams="popparams"> </ChoiceProduct>
    </el-dialog>
    <el-dialog :visible.sync="ProduceFlowSelectVisible" append-to-body>
      <ProduceFlowSelect v-if="ProduceFlowSelectVisible" ref="ProduceFlowSelect" :popparams="popparams"> </ProduceFlowSelect>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ChoiceProduct from "@/views/mes/produce/flow/ChoiceProduct";
  import ProduceFlowSelect from "@/views/mes/main/ProduceFlowSelect";
  export default {
    name: 'ProduceFlowAdd',
    components: {
      ChoiceProduct,
      ProduceFlowSelect,
    },
    props: ['popparams'],
    data() {
      return {
        ChoiceProductVisible: false,
        ChoiceProductValue: null,
        ChoiceProductDesc: null,
        ProduceFlowSelectVisible: false,
        ProduceFlowSelectValue: null,
        ProduceFlowSelectDesc: null,
        vueparams: this.getVUEParams(""),
        action_plan_work: {
          product_id: null,
          category_id: null,
        },
        loading: false,
        rules: {}
      }
    },
    created() {},
    updated() {},
    mounted() {},
    methods: {
      produceFlowAddSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/main/ProduceTraceability/produceFlowAddSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/main/ProduceTraceability/produceTraceability?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popChoiceProduct(desc, value) {
        this.ChoiceProductVisible = true;
        this.ChoiceProductDesc = desc;
        this.ChoiceProductValue = value;
      },
      closeChoiceProduct(value, desc) {
        this.ChoiceProductVisible = false;
        this.$set(this.action_plan_work, this.ChoiceProductDesc, desc);
        this.$set(this.action_plan_work, this.ChoiceProductValue, value);
      },
      popProduceFlowSelect(desc, value) {
        this.ProduceFlowSelectVisible = true;
        this.ProduceFlowSelectDesc = desc;
        this.ProduceFlowSelectValue = value;
      },
      closeProduceFlowSelect(value, desc) {
        this.ProduceFlowSelectVisible = false;
        this.$set(this.action_plan_work, this.ProduceFlowSelectDesc, desc);
        this.$set(this.action_plan_work, this.ProduceFlowSelectValue, value);
      },
    },
  }
</script>
